<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="maximum-scale=1,minimum-scale=1,user-scalable=0,width=device-width,initial-scale=1"><meta name="format-detection" content="telephone=no,email=no,date=no,address=no"><link rel="stylesheet" href="../../../global/css/aui.css"><link rel="stylesheet" href="../../../global/css/my-css.css"><style>#aui-header .bg-close{
           width: 1.4rem;
           height: 1.4rem;
        /* width: 3rem!important;
        height:2rem;
        background-image: url('../../../global/image/topic/posting_tab_delete.png');
        background-position: center;
        background-repeat: no-repeat;
        background-size: 1.4rem ; */
    }</style></head><body><header class="aui-bar aui-bar-nav" id="aui-header"><a class="aui-btn aui-pull-left" tapmode onclick="backBtn();"><img class="bg-close" src="../../../global/image/topic/posting_tab_delete.png"></a><div class="aui-title" tapmode onclick="frmToTop();">发动态</div><a id="btn-pub-moment" class="aui-btn aui-pull-right no-btn" tapmode onclick="Quick.bindPhoneProxy(onDone)(this);"><span class="c-green s-16 p-r10 p-l10">发布</span></a></header></body><script src="../../../config.js"></script><script src="../../../global/script/lib/api.js"></script><script src="../../../global/script/lib/doT.min.js"></script><script src="../../../global/script/mylib.js"></script><script src="../../../app.js"></script><script type="text/javascript">var frmName = 'frm-pub-moment';
    apiready = function() {
        window.app.init4Win();
        window.tid = '';
		$api.dom('.aui-title').innerHTML = api.pageParam.title;
        if(api.pageParam.from == 'moment-detail'){
            window.tid = api.pageParam.tid;
        }

        var header = $api.byId('aui-header');
        $api.fixStatusBar(header);
        var headerPos = $api.offset(header);
        var body_h = $api.offset($api.dom('body')).h;
        apix.openFrame({
            name: frmName,
            url: './frm.html',
            rect: {
                x: 0,
                y: headerPos.h,
                w: 'auto',
                h: 'auto'
            },
			allowEdit: true,
			pageParam: api.pageParam
        });

        // android的（硬件）返回按钮
        evt.listenTo('keyback', function(data) {
            backBtn();
        });
    };

	function backBtn() {
        api.execScript({
            frameName: 'frm-pub-moment',
            script: 'checkHasContent();'
        });
    }
    // 需要保存为草稿
    function hasContent(){
        apix.confirm({
            title: '是否保存草稿？',
            msg: '辛苦半天，还是保存一下吧',
            btnCap: {
                ok: '确定',
                cancel: '取消'
            },
            // 明确选择“确定”
            onOK: function() {
                views.closeWin();
                api.execScript({
                    frameName: frmName,
                    script: 'saveDraft();'
                });
            },
            // 明确选择“取消”
            onCancel: function() {
                // clearPostContent();
                views.closeWin();
                $api.setStorage('pubMomentStor' + window.tid, '');
            },
            onDismiss: function() {
                views.closeWin();
                $api.setStorage('pubMomentStor' + window.tid, '');
            }
        });
    }
    // 没有内容 不保存草稿 并且清空草稿
    function hasNoContent(){
        views.closeWin();
        $api.setStorage('pubMomentStor' + window.tid, '');
    }
    function closeWin(){
        views.closeWin();
    }
	function onDone(el) {
        el.disabled = true;
        setTimeout(function(){
            el.disabled = false;
        }, 5000);

        /*
        if (!app.isLoggedIn()) {
            views.openAuthWin({
                from: "publish-moment",
                fid: api.pageParam.fid || 37,
                extratype: '',
                pubFrom: ''
            });
            return;
        }
        */
        //if(hasPhone()){
            api.execScript({
                frameName: frmName,
                script: 'doPub();'
            });
        //}
	}

    function enableBtnPub() {
        wlog('enableBtnPub...');
        $apix.enable($api.byId('btn-pub-moment'));
    }
    function disableBtnPub() {
        wlog('disableBtnPub...');
        $apix.disable($api.byId('btn-pub-moment'));
    }

    // function clearPostContent(){
    //     var postContent = $apix.getStorage('postContent');
    //     if(postContent && postContent.length){
    //         for(var i=0;i<postContent.length;i++){
    //             if(postContent[i].taskId == window.taskid){
    //                 postContent.splice(i,1);
    //             }
    //         }
    //     }
    //     $apix.setStorage('postContent',postContent);
    //     views.closeWin();
    //     sendCloseInterval();
    // }
    // function sendCloseInterval(){
    //     evt.send('sendCloseInterval');
    // }</script></html>